package main

import "fmt"

func minCost(costs [][]int) int {
	dp := costs[0]

	for _, cost := range costs[1:] {
		dpNew := make([]int, 3)
		for k, v := range cost {
			dpNew[k] = v + min(dp[(k+1)%3], dp[(k+2)%3])
		}
		dp = dpNew
	}
	fmt.Println(dp)
	return min(min(dp[0], dp[1]), dp[2])
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	fmt.Println(minCost([][]int{{17, 2, 17}, {16, 16, 5}, {14, 3, 19}}))
}
